{include file="common/top" /}
<style>
html{
	background: #ffffff;
}
</style>
<form class="layui-form " action="" style="    background: #fff;">
	<div class="layui-form-item">
		<label class="layui-form-label">*项目名称：</label>
		<div class="layui-col-xs4">
			<input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入项目名称" class="layui-input">
		</div>
		<label class="layui-form-label">*客户名称：</label>
		<div class="layui-col-xs4">
			<select name="customer_id" lay-verify="required" lay-search=""  lay-verify="required" autocomplete="off">
				<option value="">直接选择或搜索选择</option>
				{volist name="customer_list" id='cu'}
					<option value="{$cu.id}" >{$cu.name}</option>
				{/volist}
	        </select>
		</div>
		
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">*项目类型：</label>
		<div class="layui-col-xs4">
			<select name="type" lay-verify="required" autocomplete="off">
				<option value="1">跑消耗</option>
				<option value="2">跑表单</option>
	        </select>
		</div>
		<label class="layui-form-label">项目状态：</label>
		<div class="layui-col-xs4">
			<input type="checkbox" lay-skin="switch" lay-filter="status" checked=true lay-text="开启|关闭" >
			<input type="hidden" name="status" value="1" >
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">*运营类型：</label>
		<div class="layui-col-xs4">
			<select name="operate_type" lay-verify="required" autocomplete="off">
				<option value="">请选择运营类型</option>
				<option value="1">自运营</option>
				<option value="2">代运营</option>
				<option value="3">纯代运营</option>
				<option value="4">代充值</option>
	        </select>
		</div>
		<label class="layui-form-label">*账户ID：</label>
		<div class="layui-col-xs4">
			<select name="op_account_id" lay-verify="required" lay-search=""  autocomplete="off">
				<option value="">直接选择或搜索选择</option>
				{volist name="acc_list" id='acc'}
					<option value="{$acc.id}" >{$acc.name_id}</option>
				{/volist}
	        </select>
		</div>
		<!-- <label class="layui-form-label">项目数量：</label>
		<div class="layui-col-xs4">
			<input type="number" name="n" value='1' placeholder="请输入项目数量" class="layui-input">
		</div> -->
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">备注：</label>
		<div class="layui-col-xs8">
			<textarea name="note" autocomplete="off" placeholder="请输入详细备注" class="layui-textarea"></textarea>
		</div>
	</div>
	
	<hr />
	<div class="layui-form-item">
		<div class="layui-input-block">
			<input type="hidden" name="channel_rebate" class="layui-input">
			<button class="layui-btn"  lay-submit="" lay-filter="demo1">添加</button>
		</div>
	</div>
	
</form>
{include file="common/footer" /}
<script>
	layui.use(['form', 'layedit', 'laydate'], function(){
		  var form = layui.form ,layer = layui.layer;
		  
		  //监听提交
		  form.on('submit(demo1)', function(data){
			var articleFrom = data.field;
			layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
			$.post("{:url('items_add')}?t=json",articleFrom,function(data){
				layer.closeAll();
				if (data['code'] == 1) { 
					var index1 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					parent.layer.close(index1); //再执行关闭 
					//父页面数据 ，重新加载
					parent.get_load(data['msg']);

				} else {
					layer.msg(data['msg'], { icon : 5 });
				}
			});
			
			return false;
		  });
		
		 //监听开关状态操作
        form.on('switch(status)', function (obj) {
        	if(this.checked){
				  $("input[name=status]").val(1);
			  }else{
				  $("input[name=status]").val(0);
			  }
            form.render();
        });
		$(".add_hy").click(function(){
			layer.prompt({title:'行业名称'},function(value, index, elem){
				layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
				$.post("{:url('industry_add')}?t=json",{name:value},function(da){
					layer.closeAll();
					if(da['code'] == 1){
						layer.msg(da['msg'], { icon : 6 });
					}else{
					 	layer.msg(da['msg'], { icon : 5 });
					}
				})
			});
		});
		
	});
	
</script>
